package cn.cdeden.knowledge.service;

import cn.cdeden.common.core.utils.page.TableDataInfo;
import cn.cdeden.knowledge.domain.FileTemplateTree;
import cn.cdeden.knowledge.domain.Template;
import cn.cdeden.knowledge.domain.dto.FileTemplateTreeDto;
import cn.cdeden.knowledge.domain.dto.TemplateTreeQueryParam;
import com.baomidou.mybatisplus.extension.service.IService;
import io.undertow.util.BadRequestException;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

public interface FileTemplateTreeService extends IService<FileTemplateTree>{

    TableDataInfo<Template> queryTemplate(TemplateTreeQueryParam query, Pageable pageable);

    List<FileTemplateTree> queryHotName(Integer size);

    TableDataInfo<Template> queryCollectionTemplate(TemplateTreeQueryParam query, Pageable pageable);

    List<FileTemplateTree> getTemplateFile(List<Long> treeNodeIds);

    boolean uploadTemplateToCommon(FileTemplateTree fileTemplateTree);

    void isAddCollection(Long templateId, Boolean isAdd);

    void removePersonalTemplate(Long id) throws BadRequestException;

    FileTemplateTreeDto findById(Long id);

    boolean uploadPersonalTemplate(FileTemplateTree fileTemplateTree);

    boolean uploadEnterpriseTemplate(FileTemplateTree fileTemplateTree);

    boolean uploadPersonalTemplateToCommon(FileTemplateTree fileTemplateTree);

    boolean uploadEnterpriseTemplateToCommon(FileTemplateTree fileTemplateTree);

    FileTemplateTreeDto useTemplate(FileTemplateTreeDto fileTemplateTreeDto) throws IOException;

    void updateTemplate(Long id, Long parentId, Long deptId, String name, MultipartFile file, MultipartFile image);

    void uploadTemplateAdmin(Long parentId, List<MultipartFile> files, Long deptId);

    void uploadTemplateAdmin(Long parentId, Long deptId, String name, MultipartFile file, MultipartFile image);

    FileTemplateTreeDto createTemplateCenter(Long id, String realName, String type, String state, String classifyId);

    @Transactional(rollbackFor = Exception.class)
    int insertDto(FileTemplateTreeDto dto);

    TableDataInfo<Template> queryEnterpriseTemplate(String type, String realName, Long parentId, Pageable pageable);

    void removeEnterpriseTemplate(Long id);

    void createTemplate(MultipartFile image, MultipartFile file, String realName, String parentId, String state);
}
